;
(function() {
  getProduct(function(arr) {
    method.getProjectNumber(arr)
  }, function(arr) {}, function(arr) {})

  var method = {
    getProjectNumber: function(arr) {
      hlhttp.get({
        url: 'user/fn_project_count,wf_project_count',
        data: {
          project_ids: arr[1].join(',')
        },
        success: function(res) {
          if (!res) {
            $('.project-chart-bb').hide()
          }
          var arr = [['运营中',Number(res.fnProjectCount)],['筹备中',Number(res.wfProjectCount)]]
          var count = Number(res.fnProjectCount)+Number(res.wfProjectCount);
          setTimeout(function() {
            method.chart(arr,count)
          }, 300);
        }
      })
    },
    chart: function (data,count) {
      var options = {
        colors: [
          '#5E66A5',
          '#9AA2E2'
        ],
        title: {
            text: '<div style="color:#f7cf6a;font-size:14px;text-align:center;">' + count + '</div>' + '<br/>' + '项目总数(个)',
            style: { fontSize: '12px' },
            align: 'center',
            verticalAlign: 'middle',
            useHTML:true,
            y: 15
        },
        legend:{
          enabled:true,
          itemStyle:{ color: '#333', fontWeight:'normal' }
        },
        tooltip: {
          shared: true,
          enabled: true,
          valueDecimals: 2,
          headerFormat: '<span class="font-size:14px">{point.key}</span>',
          pointFormat: '项目数: {point.y:.1f}'+'个',
          borderWidth: 0,
          style: {
            fontSize: '14px'
          }
        },
        plotOptions: {
          pie: {
            dataLabels: {
              enabled: false,
              distance: -30,
              style: {
                  fontWeight: 'bold',
                  color: 'white',
                  textShadow: '0px 1px 2px black'
              }
            },
            startAngle: -120,
            endAngle: 120,
            center: ['50%', '75%'],
            showInLegend: true,
          }
        },
        series: [{
            type: 'pie',
            innerSize: '65%',
            data: data
        }]
      }
      $('.project-rz-chart').highcharts(options)
    }
  }

}())
